<?php

class Application_Form_Mesreponses extends Zend_Form
{

    public function init()
    {
        /* Form Elements & Other Definitions Here ... */
    	
    	
    	
    	$reponse=new Application_Model_Mapper_Sondage();
    	$res=$reponse->getsondage( Zend_Controller_Front::getInstance()->getRequest()->getParam("id") );
    	 
    	foreach ($res as $key => $value){
    		 
    		$reponseliste=array();
    		if(isset($value['reponses'])){
    			foreach ($value['reponses'] as $keyreponse => $valuereponse){
    				$reponseliste[$valuereponse['id']."_".$valuereponse['score']]=$valuereponse['label'];
    			}
    		}
    		
    		
    		if ($value["question"]["score"]<=1){
    			$element = new Zend_Form_Element_Radio("Question_".$key);
    			$element->setMultiOptions($reponseliste);
    			$element->setLabel($value["question"]["label"]);
    			$this->addElement($element);
    			
    		}else{
    			$element = new Zend_Form_Element_MultiCheckbox("Question_".$key,array(
    				'multiOptions' => $reponseliste
    			)) ;
    			$element->setLabel($value["question"]["label"]);
    			$this->addElement($element);
    		}
    		
    	
    		
    	}
    	
    	$submit = new Zend_Form_Element_Submit('submit',"Save");
    	$element = $this->addElement($submit);
    	
    	$this->setDecorators( array( array('ViewScript', array('viewScript' => 'slideform.phtml'))));
    }


}

